package com.jiangyao.controller;


import com.github.pagehelper.PageInfo;
import com.jiangyao.common.ApiResult;
import com.jiangyao.model.dto.backend.UserSearchDTO;
import com.jiangyao.model.dto.backend.JobUserDto;
import com.jiangyao.model.dto.backend.UserResumeDTO;
import com.jiangyao.model.vo.backend.JobUserVO;
import com.jiangyao.model.vo.backend.UserBaseVO;
import com.jiangyao.model.vo.backend.UserResumeVO;
import com.jiangyao.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 成员表 前端控制器
 * </p>
 *
 * @author xiangyan
 * @since 2020-08-11
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;

    @ApiOperation(value = "获取职位投递成员列表", notes = "必填字段：orgId，jobId")
    @PostMapping("/getJobUserList")
    public ApiResult<PageInfo<JobUserVO>> getJobUserList(@Validated @RequestBody JobUserDto jobUserDto) {
        return ApiResult.success(userService.getJobUserList(jobUserDto));
    }

    @ApiOperation(value = "获取用户在线简历", notes = "必填字段：orgId，jobId")
    @PostMapping("/getUserResume")
    public ApiResult<UserResumeVO> getUserResume(@Validated @RequestBody UserResumeDTO userResumeDTO) {
        return ApiResult.success(userService.getUserResume(userResumeDTO));
    }

    /**
     * 根据姓名检索用户（最多返回50）,用于选择用户时
     *
     * @param searchDTO 检索账号DTO
     * @return 结果
     */
    @ApiOperation(value = "根据姓名检索用户（最多返回50）,用于选择用户时")
    @PostMapping("/searchForSelect")
    public ApiResult<UserBaseVO> searchForSelect(@RequestBody UserSearchDTO searchDTO) {
        return ApiResult.success(userService.searchForSelect(searchDTO));
    }
}

